package com.starter.knife4j.config;

import com.github.xiaoymin.knife4j.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @className: com.demo.common.config.swagger-> WebMvcConfigurerConfig
 * @description: mvc配置类
 * @author: wuyijie
 * @createDate: 2021/5/19 22:13
 */
public class WebMvcConfigurerConfig implements WebMvcConfigurer {
    @Value("${spring.application.name}")
    private String applicationName;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        if (StrUtil.isBlank(applicationName)) {
            applicationName = "";
        }
        registry.addResourceHandler( "/swagger/doc.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler( "/swagger/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}
